﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using NExplorer.Commands;
using NExplorer.Properties;

namespace NExplorer
{
	static class Program
	{
		[STAThread]
		static void Main()
		{
			Application.ThreadException += Application_ThreadException;
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(true);

			ServiceManager.AddService(new ExplorerService(), typeof(IExplorerService));
			ServiceManager.AddService(new MenuBuilderManager(), typeof(IMenuBuilderManager));
			ServiceManager.AddService(new ColumnProviderManager(), typeof(IColumnProviderManager));
			ServiceManager.AddService(new FileOperations());

			MainForm form = new MainForm();

			ServiceManager.AddService(form.ToolBar, typeof(IMainToolBar));

			ServiceManager.ToolBar.AddButton(new UpOneFolderCommand(), Keys.Alt | Keys.Up);
			
			AddInManager.LoadAddIns();

			Application.Run(form);

			Settings.Default.Save();
		}

		static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
		{
			MessageBox.Show("The following unhandled exception has occurred:\n\n" + e.Exception.ToString(), "Unhandled Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
		}
	}
}
